package com.newedu.healthtest.utils;

import org.apache.commons.io.FileUtils;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;
import org.openqa.selenium.WebDriver;

import java.io.File;
import java.io.IOException;

/**
 * @author fujun
 * @create 2021-10-29 09:21:58
 * @company 新开普电子股份有限公司
 */
public class DriverUtils {
    public static WebDriver driver;

    public static File takeScreenShot(String path)
    {
        WebDriver driver = DriverUtils.driver;
        File destFile = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
        try {
            FileUtils.copyFile(destFile, new File(path));
        } catch (IOException e) {
            e.printStackTrace();
        }
        return destFile;
    }
}
